import 'package:enterprise_v6_app/app/components/me_regional_organization_tree/regional_organization_tree_view.dart';
import 'package:enterprise_v6_app/app/core/core.dart';
import 'package:enterprise_v6_app/app/modules/task/task_all/risk_control/risk_control_approve/risk_control_approve_detail/risk_control_approve_detailinfo/risk_control_approve_detailinfo_controller.dart';

///基本信息
class RiskControlApproveDetailInfoPage extends StatelessWidget {
  RiskControlApproveDetailInfoPage({super.key});

  final controller = Get.put(RiskControlApproveDetailInfoController());

  @override
  Widget build(BuildContext context) {
    return GetBuilder(
        init: controller,
        builder: (_) {
          return Scaffold(
            key: controller.riskRightScaffoldKey,
            backgroundColor: AppColors.bg_color_grey,
            body: SingleChildScrollView(
              child: Column(
                crossAxisAlignment: CrossAxisAlignment.start,
                children: [
                  _title(controller.data?.riskObjectName ?? '', ''),
                  _titleBg(),
                  _title('责任部门:',controller.data?.hazardDep??''),
                  _title('责任人:',  controller.data?.hazardLiablePerson??''),
                  _title('风险分析单位辨识部门:',  controller.data?.hazardDistinguishDep??''),
                  _title('风险分析单位辨识人:',controller.data?.hazardDistinguishPerson??''),
                  _title('装置名称:', controller.data?.deviceName ?? ''),
                  MeRegionalOrganizationTreePage(id: controller.item.id ?? ''),
                ],
              ),
            ),
          );
        });
  }

  Widget _title(String title, String? value) {
    return Container(
      padding: EdgeInsets.only(top: 4.w, bottom: 4.w),
      child: Row(
        children: [
          AppGaps.hGap10,
          Text(
            title,
            style: TextStyle(
              color: Colors.black,
              fontSize: 12.sp,
            ),
          ),
          if (value != null)
            Expanded(
                child: Text(
              value,
              style: TextStyle(
                color: const Color(0xFF7C7D93),
                fontSize: 14.sp,
              ),
            )),
        ],
      ),
    );
  }

  /// 标题背景分隔栏
  Widget _titleBg() {
    return Column(
      children: [
        AppGaps.vGap6,
        Container(
          height: 2.w,
          color: const Color(0xFF587DF5),
        ),
      ],
    );
  }
}
